﻿<!DOCTYPE HTML>
<html>
{include file="public:header_css"}
<body>
<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 班级管理 <span class="c-gray en">&gt;</span> 班级列表
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a class="btn btn-primary radius" href="{:url('add')}">
				<i class="Hui-iconfont">&#xe600;</i> 添加班级
			</a>
		</span>
		<form class="form-inline" role="form" method="get">
			<div id="" class="" style="margin-left: 50px;margin-left: 250px;height: 10px;">
				<label>门店查找:
					<select style="width:15%;" class="input-text" id="keywords1" name="keywords1">
						<option value="0"  style="width:100%;">请点击选择</option>
						{foreach name="store_list" item="val" key="key"}
						<option value="{$val['store_id']}"  style="width:100%;" {if $keywords1==$val.store_id} selected {/if}>{$val['store_name']}</option>
						{/foreach}
					</select>
					<button class="btn btn-primary radius" type="submit" id="submit1"  style="margin-top: -4px;">&nbsp;&nbsp;搜索&nbsp;&nbsp;</button>
					<button class="btn btn-warning radius" type="submit" id="reset1"  style="margin-top: -4px;">&nbsp;&nbsp;重置&nbsp;&nbsp;</button>
				</label>
			</div>
		</form>
        <span class="r">共有班级：<strong>{$total}</strong></span>
	</div>

    <div class="mt-20">
		<table class="table table-border table-bordered table-bg table-sort">
			<thead>
				<tr class="text-c">
					<th width="60">班级编号</th>
					<th width="100">门店名称</th>
					<th width="100">班级名称</th>
                    <th width="100">操作</th>
				</tr>
			</thead>
			<tbody id="shopList">
				{foreach name="list" item="val" key="key"}
					<tr class="text-c">
						<td>
							{$val.class_id}
						</td>
						<td class="text-m">
							{$val.store_name}
						</td>
						<td class="text-m">
							{$val.class_name}
						</td>
						<td class="f-14 product-brand-manage">
							<a class="label label-success radius" href="{:url('edit', array('class_id'=>$val.class_id))}">点击编辑</a>

							{if $val['status'] == 0}
							<span class="label label-success radius" onClick="is_use('{$val.class_id}',1)"  style="margin-left: 20px">点击闭班</span>
							{else /}
							<span class="label label-danger radius" onClick="is_use('{$val.class_id}',0)" style="margin-left: 20px">点击开班</span>
							{/if}
						</td>
					</tr>
				{/foreach}
				{if count($list)<=0 }
					<tr class="text-c">
						<td colspan="6">
							暂无数据
						</td>
					</tr>
				{/if}
			</tbody>
		</table>
	</div>
	{$page}
</div>

{include file="public:footer_js"}

<script type="text/javascript" src="__STATIC__/admin/lib/layer/2.4/layer.js"></script>

<script type="text/javascript">

    function is_use(class_id,status) {

        var notice = "确定关闭吗？";
        if (status == 0){
            notice = "确定开启吗？";
        }else if(status === 1){
            notice = "确定关闭吗？";
        }
        //异步提交
        layer.confirm(notice,function (index) {
            $.ajax({
                type:"POST",
                url:"{:url('is_use')}",
                data:{
                    class_id  : class_id,
                    status    : status
                },
                async:true,
                success:function (res) {
                    if(res.code === 1){
                        layer.msg(res.msg,{icon:6,time:1000});
                        //刷新可修改数据
                        setTimeout(function () {
                            location.replace(location.href);
                        },2000);

                    }else{
                        layer.msg(res.msg,{icon:5,time:1000});
                    }
                },
                error:function (res) {
                    console.log(res.data);
                }
            });

        })
    }

    //刷新
    $('#reset1').click(function () {
        $('#keywords1').val('');
    })

</script>
</body>
</html>